/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.notify.web;

import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.notify.entity.NotiUserOnline;
import com.thinkgem.jeesite.modules.notify.service.NotiUserOnlineService;
import com.thinkgem.jeesite.modules.notify.service.dto.NotiUserOnlineServiceODTO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 推送用户在线图表Controller
 *
 * @author hf
 * @version 2018-12-24
 */
@Controller
@RequestMapping(value = "${adminPath}/notify/notiUserOnline")
public class NotiUserOnlineController extends BaseController {

    @Autowired
    private NotiUserOnlineService notiUserOnlineService;

    @ModelAttribute
    public NotiUserOnline get(@RequestParam(required = false) String id) {
        NotiUserOnline entity = null;
        if (StringUtils.isNotBlank(id)) {
            entity = notiUserOnlineService.get(id);
        }
        if (entity == null) {
            entity = new NotiUserOnline();
        }
        return entity;
    }

    @RequiresPermissions("notify:notiUserOnline:online")
    @RequestMapping(value = {"useronline", ""})
    public String userOnline(Model model) {
        NotiUserOnlineServiceODTO appUserOnline = notiUserOnlineService.getAppUserOnline();
        model.addAttribute("appUserOnline", appUserOnline);
        return "modules/notify/notiUserOnline";
    }

    /*@RequestMapping(value = {"userOnlineNum", ""})
    @ResponseBody
    public NotiUserOnlineServiceODTO userOnlineNum(Model model) {
        NotiUserOnlineServiceODTO appUserOnline = notiUserOnlineService.getAppUserOnline();
        return appUserOnline;
    }*/
    /*@RequiresPermissions("notify:notiUserOnline:view")
    @RequestMapping(value = {"list", ""})
    public String list(NotiUserOnline notiUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<NotiUserOnline> page = notiUserOnlineService.findPage(new Page<NotiUserOnline>(request, response), notiUserOnline);
        model.addAttribute("page", page);
        return "modules/notify/notiUserOnlineList";
    }

    @RequiresPermissions("notify:notiUserOnline:view")
    @RequestMapping(value = "form")
    public String form(NotiUserOnline notiUserOnline, Model model) {
        model.addAttribute("notiUserOnline", notiUserOnline);
        return "modules/notify/notiUserOnlineForm";
    }

    @RequiresPermissions("notify:notiUserOnline:edit")
    @RequestMapping(value = "save")
    public String save(NotiUserOnline notiUserOnline, Model model, RedirectAttributes redirectAttributes) {
        if (!beanValidator(model, notiUserOnline)) {
            return form(notiUserOnline, model);
        }
        notiUserOnlineService.save(notiUserOnline);
        addMessage(redirectAttributes, "保存推送用户在线图表成功");
        return "redirect:" + Global.getAdminPath() + "/notify/notiUserOnline/?repage";
    }

    @RequiresPermissions("notify:notiUserOnline:edit")
    @RequestMapping(value = "delete")
    public String delete(NotiUserOnline notiUserOnline, RedirectAttributes redirectAttributes) {
        notiUserOnlineService.delete(notiUserOnline);
        addMessage(redirectAttributes, "删除推送用户在线图表成功");
        return "redirect:" + Global.getAdminPath() + "/notify/notiUserOnline/?repage";
    }*/

}